home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / MacWT 0.9 / wt Mac Source / RDriver.h < prev    next >
Encoding:
Text File  |  1995-10-10  |  7.8 KB  |  255 lines  |  [TEXT/CWIE]

  1. /********************                        ***********************/
  2. //
  3. //    Player PRO 4.3x -- MAD Music Driver Definition
  4. //
  5. //    Library Version 2.7
  6. //
  7. //    To use with MusicLibrary for Think C & CodeWarrior
  8. //
  9. //    Antoine ROSSET
  10. //    16 Tranchees
  11. //    1206 GENEVA
  12. //    SWITZERLAND
  13. //    
  14. //    FAX:            (+41 22) 346 11 97
  15. //    Compuserve:        100277,164
  16. //    Internet:         rosset@dial.eunet.ch
  17. //
  18. /********************                        ***********************/
  19.  
  20. #define MAX_ARP 3
  21. #define NUMBER_FINETUNES 17
  22. #define AMIGA_CLOCKFREQ 33659820
  23. #define MIN_PITCH 142
  24. #define MAX_PITCH 17161L
  25. #define MIN_VOLUME 0
  26. #define MAX_VOLUME 64
  27. #define ACCURACY 12
  28. #define fix_to_int(x) ((x) >> ACCURACY)
  29. #define int_to_fix(x) ((x) << ACCURACY)
  30. //#define    FREQBASE        152L
  31. #define MAXTRACK        32
  32. #define MAXINSTRU        64
  33. #define MAXPATTERN        200
  34. #define NUMBER_NOTES    84
  35.  
  36. /********************                        ***********************/
  37. /***                  Voice structure definition                    ***/
  38. /********************                        ***********************/
  39.  
  40. struct VoiceActive    {
  41.         Ptr            MaxPtr;
  42.         Ptr            InstruVoice;
  43.         Ptr            StartPtr;
  44.         long        loopWord;
  45.         long        loopWords;
  46.         
  47.         short        Instru;
  48.         short        InstruOld;
  49.         
  50.         short        Amiga;
  51.         short        AmigaOld;
  52.         
  53.         short        pitch;
  54.         short         realpitch;
  55.         short        Prerealpitch;        // For vibratoE !!!
  56.         
  57.         short        volume;
  58.         short         effect;
  59.         Byte        arg;
  60.         
  61.         short         arp[MAX_ARP];
  62.         short         arpindex;
  63.         
  64.         short        viboffset;
  65.         short         vibdepth;
  66.         short         slide;
  67.         short         pitchgoal;
  68.         
  69.         short         pitchrate;
  70.         short        oldpitchrate;
  71.         
  72.         short         volumerate;
  73.         
  74.         short         vibrate;
  75.         short        oldvibrate;
  76.         
  77.         short         retrig;
  78.         
  79.         short        ID;
  80.         short        amplitude;
  81.         
  82.         Ptr            samplePtr;
  83.         
  84.         Boolean        repeat;
  85. };
  86. typedef        struct VoiceActive    VoiceActive;
  87.  
  88. /********************                        ***********************/
  89. /***              Music description used in driver                ***/
  90. /********************                        ***********************/
  91.  
  92. struct    MADPartition
  93. {
  94.         MADSpec*                header;
  95.         struct    MusicPattern*    partition[ MAXPATTERN];
  96.         Ptr                        instrument[ MAXINSTRU];
  97. };
  98. typedef        struct MADPartition    MADPartition;
  99.  
  100. /********************                        ***********************/
  101. /***                    PlayerPRO variables                        ***/
  102. /********************                        ***********************/
  103.  
  104. #ifdef MainSystemPlayerPRO
  105. #define EXT
  106. #else
  107. #define EXT extern
  108. #endif
  109.  
  110. EXT    MADPartition            thePartition;                        // Current music in memory, loaded with RLoadMusic() by example
  111. EXT    MADSpec                    *theFileInt;                        // Current music header == thePartition.header
  112. EXT    VoiceActive                theVoiceActive[ MAXTRACK];            // Current driver voices
  113. EXT    short                    DriverTypeInt;                        // Actual driver type
  114. EXT    short                    Tube[ MAXTRACK];                    // Used in 'Tracks View' Window - View menu
  115. EXT short                    PartitionReader;                    // Current position in pattern (0...64)
  116. EXT short                    Pat;                                // Current ID Pattern, see 'Patterns list'
  117. EXT short                    PL;                                    // Current position in partition, see 'Partition list'
  118. EXT    short                    VolExt[ MAXTRACK];                    // Volumes settings, see 'Adaptators' window
  119. EXT    short                    speed;                                // Current speed, see speed Effect
  120. EXT    short                    finespeed;                            // Current finespeed, see speed Effect
  121. EXT    short                    InstruTube[ MAXINSTRU];                // Used in 'Instrument View' Window - View menu
  122. EXT    short                    VExt;                                // External music speed, see 'Adaptators' window
  123. EXT    short                    FreqExt;                            // External music pitch, see 'Adaptators' window
  124. EXT    short                    DriveTrackNo;                        // Actual number of tracks
  125. EXT    short                    DriveOutBit;                        // Output bit: 8 or 16 bits
  126. EXT    Boolean                    PtrSystem;                            // Use NewPtr or NewPtrSys ?
  127. EXT    Boolean                    Reading;                            // Reading indicator
  128. EXT    Boolean                    MusiqueFertig;                        // Is your music finished?
  129. EXT short                    LeftRight[ MAXTRACK];                // Left/Right % for Deluxe Driver
  130.  
  131. /* DO NOT MODIFY OR USE these variables */
  132.  
  133. EXT short                    smallcounter, trackDiv;
  134. EXT    long                    DBTick, ASCBUFFER, VINTERNAL, FREQBASE;
  135. EXT    short                    **FreqHandle, InstruActif[ MAXINSTRU];
  136. EXT    Ptr                        SysHeapPtr, Vol, IntPtr[ 2], PseudoBuf[ 2];
  137. EXT    Boolean                    SMTicker, RepeatMusic, JumpToNextPattern;
  138. EXT    long                    oldNotePosAA, SInc, VMOD;
  139. EXT    Boolean                    DriveStereo, PtrSystem, JumpToNextPattern, RepeatMusic, AntiAliasing;
  140.  
  141. extern    short    Tuning[ ], vibrato_table[ ];
  142.  
  143. /********************                        ***********************/
  144. /***                        DRIVERS ID                            ***/
  145. /***             DO NOT USE MIDIClassic Driver !!!!                ***/
  146. /********************                        ***********************/
  147.  
  148. enum {
  149.     ASCMono = 1,
  150.     ASCStereo = 2,
  151.     SMMono = 3,
  152.     SMStereo = 4,
  153.     SMDSP = 5,
  154.     SMPolyPhonic = 6,
  155.     MIDIClassic = 7,
  156.     AWAC = 8,
  157.     SMDELUXE = 9,
  158.     SMDELUXE8 = 10
  159. };
  160.  
  161. /********************                        ***********************/
  162. /***                        EFFECTS ID                            ***/
  163. /********************                        ***********************/
  164.  
  165. enum {
  166.         arpeggioE         = 0,
  167.         downslideE         = 1,
  168.         upslideE         = 2,
  169.         portamentoE     = 3,
  170.         vibratoE         = 4,
  171.         portaslideE     = 5,
  172.         vibratoslideE    = 6,
  173.         nothingE         = 7,
  174.         offsetE         = 9,
  175.         slidevolE         = 10,
  176.         fastskipE         = 11,
  177.         volumeE         = 12,
  178.         skipE             = 13,
  179.         extendedE         = 14,
  180.         speedE             = 15
  181.     };
  182.  
  183. /********************                        ***********************/
  184. /*                General Function Description                      */
  185. /*      For more informations about these functions, e-mail me    */
  186. /********************                        ***********************/
  187.  
  188.  
  189. /********************                        ***********************/
  190. /***                     EXTERNAL ROUTINES                         ***/
  191. /*** See Documentation for more informations on these routines  ***/
  192. /********************                        ***********************/
  193.  
  194. OSErr    RInitMusic( short, short);                    // Music Driver initialization
  195. OSErr    RPlayMusic( void);                            // Play the current music
  196. OSErr    RStopMusic( void);                            // Stop the current music
  197. OSErr    RResetMusic( void);                            // Reset the current music at the start position
  198. OSErr    RQuitMusic( void);                            // Dispose the music driver, use it after RInitMusic()
  199.  
  200. OSErr    RLoadMusic( Str255 fName);                    // Load a MAD File in the current directory
  201. OSErr    RLoadMusicRsrc( OSType IDName, short IDNo);    // Load a MAD Rsrc into memory
  202. OSErr    RInstallMADF( MADPartition aPartition);        // Install directly a MAD partition
  203. OSErr    RClearMusic(void);                            // Dispose the current music, use it after RLoadMusic(), RLoadMusicRsrc(), RInstallMADF()
  204.  
  205.  
  206. void    ConvertMod2Mad( Ptr aMOD, long Size, MADPartition *theMAD);    // Convert MOD to MAD
  207. Ptr        ConvertMad2Mod( MADPartition *theMAD, long Size);            // Convert MAD to MOD
  208. void    ChangeTrackNo( short);                        // Change current tracks number of the music driver
  209. void    CleanDriver();                                // Clean the driver
  210. struct Command* GetCommand( short PosX, short    TrackIdX, struct MusicPattern*    tempMusicPat);    // Extract a Command from a MusicPattern    
  211. OSErr RPlaySound( Ptr whichSound, long SoundSize, short whichTrack, long Period, short Amplitude);    // Play a sound with an amplitude on a track at a period
  212.  
  213. /********************                        ***********************/
  214. /***                     INTERNAL ROUTINES                        ***/
  215. /***                DO NOT use these routines                    ***/
  216. /********************                        ***********************/
  217.  
  218. void    Sampler8in8Add( VoiceActive *curVoice, register Ptr    ASCBuffer);
  219. void    Sampler16Add( VoiceActive *curVoice, register short    *ASCBuffer);
  220.  
  221. void    NoteAnalyse( void);
  222.  
  223. void    ClearVol4();
  224. OSErr    SetUpFrequence( long, long);
  225. OSErr    ReadInstrument( short, Boolean, Handle);
  226. void    DoEffect( VoiceActive *, short);
  227. OSErr    DBSndClose();
  228. void    StopChannel();
  229. OSErr     SetMODVol4( long , long , Boolean );
  230. void    PlayChannel();
  231. void     checkpitch( VoiceActive *, Boolean);
  232. void     BufferCopyM();
  233. void     BufferCopyS();
  234. void    InstallMODVBL(void);
  235. void     ReadNote( VoiceActive *curVoice, struct Command        *theCommand);
  236. void    RemoveMODVBL(void);
  237. void    MODRelance(void);
  238. void    Play(void);
  239. void    VIAOn(void);
  240. void     SndOff(void);
  241. void     SndOn(void);
  242. void    VIAOn2(void);
  243. void     VIAOn3(void);
  244. OSErr    InitDBSoundManager( long);
  245. void     SetUpEffect( VoiceActive *ch);
  246. Boolean DirectSave( Ptr, Boolean, short);
  247. void    ChangeSpeed( void);
  248. void    Play16Stereo( void);
  249. void    Play8Stereo( void);
  250. void    Play8Mono( void);
  251. long    decode32 (void *msg_buf);
  252. short    decode16 (void *msg_buf);
  253. long    Tdecode32 (void *msg_buf);
  254. short    Tdecode16 (void *msg_buf);
  255. void     ClearFrequence();